SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00008 1 05-26-9406:11ALL SWAG SUPPORT TEAM Vintage Pascal FAQ SWAG9405 20 ~O SECTION 4 - Vintage PascalππThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.π πTI407 Using the serial port in a Pascal applicationπTI152 Interupt handler for 3.X and lowerπTI226 Async routines for versions 3.X and lowerπTI232 Absolute disk read for version 3.x and lowerππQ. "Are any of the ToolBox programs that shipped with versionsπ 3.0 and 4.0 still available. For instance, can I get anπ upgraded copy of the Database ToolBox or the Editorπ ToolBox."ππA. No. These programs are no longer in any form from anyπ company. If you want to get a copy of them, you would needπ to purchase them from a current owner.ππQ. "Can the ToolBox programs be used from version 7.0?"ππA. It depends. As a rule, the answer is yes, all you need to doπ is recompile and they will run fine. This is totallyπ fortuitous, however, and Borland has, and will, do nothingπ to update these programs. See TI1728 for help upgrading theπ Editor ToolBox.ππQ. "How can I convert my Turbo Pascal 3.0 program to versionπ 7?"ππA. There is a file called up UPGRADE.ZIP which is available onπ the forums. This can help in the process of upgrading theπ files. Most of the code from version 3.0 will run fine underπ 7.0, but not all of it.ππQ. "When I use the Turbo Vision editors unit from Version 6.0 Iπ never see the numbers 3, 4, 6 and 7 when I try to type themπ in." ππA. This was a bug in the first version of TP6.0. The fix isπ available in EDITOR.PAT, found in LIB1.ππQ. "What ever happened to FreeMem and FreePtr?"ππA. These Turbo Pascal 5.x identifiers are no longer used by theπ heap manager. Simply delete references to FreeMin from yourπ code. If you're using routines that use FreePtr to compressπ the heap or perform other implementation-dependentπ operations on the heap, you'll need to update theseπ routines. (If you just need to lower the top of memory inπ order to do an Exec, you can call the SetMemTop procedureπ from the Turbo Vision Memory unit.) See the Programmer'sπ Guide for more information about how the heap managerπ works.π π 2 05-26-9406:11ALL SWAG SUPPORT TEAM Graphics - FAQ SWAG9405 18 ~O SECTION 5 - GraphicsππThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.π πTI432 Printing graphics to an HP LaserJetπTI433 Printing graphics to an EpsonππQ. "Does Turbo Pascal run in Super VGA modes?"ππA. Yes, if you have a VESA compatable video card you can useπ the VESA16.BGI file to get high resolutions such as 1024X768π or 800X600. If you also want 256 color support, you shouldπ turn to a third party solution. There are some helpfulπ files, including freeware drivers, available here on theπ forum.ππQ. "How can I print my graphics code?"ππA. Download the files labeled TI432.ZIP and TI433.ZIP from π the libraries. Additional support is available from third π party vendors. You could pose a question in the forum askingπ for recommendations regarding third party graphics support π for printing.ππQ. "When will Borland upgrad the GRAPHICS TOOLBOX?"ππA. The GRAPHICS TOOLBOX is no longer available from Borland inπ any form, and there are absolutely no plans to upgrade it.π It should, however, recompile with recent versions ofπ Pascal including Versions 6.0 and 7.0.ππQ. "How can I use BGI calls in Windows?"ππA. Windows is a graphical operating environment, so there isπ no longer any need for the BGI when programming Windows. Youπ will find that Windows has built in support for graphicsπ that is much superior to anything available in the BGI unit.π To get started, try using using the manuals and on-line docsπ to read about the Windows GDI.ππQ. "How can I add a mouse to my Graphics programs?"ππA. Outside of Windows, Borland offers no built in support forπ the mouse in your programs. However, adding mouse supportπ is extremely simply. Those who know ASSEMBLER can add mouseπ support with the INT33 interface, others will find MOUSEπ libraries available here in the CIS libraries.π 3 05-26-9406:12ALL SWAG SUPPORT TEAM Protected Mode FAQ SWAG9405 26 ~O SECTION 6 - Protected Mode Programmingπ πThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.ππTI1184 Overview of Borland Pascal 7.0 and Turbo Pascal 7.0πTI1722 Declaring an array on the heap πTI1760 Creating a temporary stack in real or protected mode πTI1188 Creating protected mode apps with Borland Pascal πTI1171 Problem Report Form πTI1719 Booting CleanππNEWRTM.ZIP Latest RTM.EXE and DPMI16BI.OVL πPASALL.ZIP Collection of Technical Information sheets from π 1986 on πEZDPMI.ZIP Unit encapsulating all common DPMI requirements for π protected mode programmingπBIGSTU.PAS How to cope with memory allocations > 64KπMOUSE.ZIP General Purpose mouse unit for text/graphics modeππQ. "When using the BP7 IDE to compile a protected modeπ application, how do I step through the code like I do withπ real mode applications?"ππA. To debug protected mode programs, you must use the externalπ debugger (TDX). You can put it on the TOOLS menu to makeπ it just a keystroke away.ππQ. "When I convert a program from Real Mode to Protected Mode,π do I have to change the GetMem calls to GlobalAlloc andπ GlobalDiscard?" ππA. No, you don't have to change the GetMem calls. GetMem is aπ better allocation method. Getmem will do a better job ofπ allocating memory. It allocates the memory in 8K chunks,π then suballocates from that. The reason for this is thatπ there are a maximum of 2000 selectors availble in BP7, soπ you don't want to waste them. GlobalAlloc calls the DPMIπ directly to allocate the memory, bypassing the heap manager.π GlobalAlloc is there for when you need to bypass the heapπ manager for some reason, but you normally don't want to doπ that.ππQ. "How do I profile a protected mode application using BP7?"ππA. You can only profile real mode applications, Borland doesπ not supply a protected mode profiler. ππQ. "I have ported a large program to protected mode and amπ getting a General Protection Fault on calls to GetMem. Whatπ could be causing this?"ππA. In DPMI, a Local Descriptor Table (LDT) can contain 8192π selectors. The Run Time Manager (RTM) maintains anπ internal table to track allocated selectors. The RTM tableπ has a capacity of approximately 2K selectors. GlobalAllocπ and GetMem calls that need to allocate a new block will failπ when that 2K table is full.ππQ. "I have a protected mode application that was created withπ BP7. When running the program in a DOS box under Windows,π the computer locks up. What could be causing this?"ππA. Check the "XMS KB Required" and "XMS KB Limit" settings inπ the .PIF file used for the DOS box. The "Required" settingπ should be 0 and the "Limit" should be at least 2048K.π 4 05-26-9406:12ALL SWAG SUPPORT TEAM DOS Proramming FAQ SWAG9405 34 ~O SECTION 7 - DOS Programmingπ πThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.π πTI1184 Overview of Borland Pascal 7.0 and Turbo Pascal 7.0πTI1722 Declaring an array on the heapπTI1760 Creating a temporary stack in real or protected modeπTI1171 Problem Report FormπTI1719 Booting CleanππLC2P01.FAQ Linking C to Pascal Frequently Asked QuestionsπEZDPMI.ZIP Unit encapsulating common DPMI requests forπ protected mode programming πBIGSTU.PAS How to cope with memory allocations > 64K πPASALL.ZIP Collection of Technical Information Sheets from π 1986 onπNEWRTM.ZIP Latest RMT.EXE and DPMI16BI.OVLπMOUSE.ZIP General purpose mouse unit for text/graphic modesππQ. "How do I link an object file that is a library ofπ functions created in C?"ππA. Download the file "LC2P01.FAQ. The C run-time library isπ needed by the object file. Since Pascal can't link the Cπ RTL as is, you will need the RTL source and will need toπ modify it so that it can be linked by TP.ππQ. "How do I get the ASCII key numbers for the Arrow keys?"ππA. Below is a short program that reveals this information.ππ program DisplayAscii;π uses Crt;π varπ ch:char;π beginπ repeat { repeat until Ctrl-C }π ch := Readkey;π Write(Ord(CH):4);π until ch = ^C; π end.ππ The program can be terminated by pressing Ctrl-C. You'llπ see that keypresses such as UpArrow actually generated twoπ bytes: a zero followed by the extended key code. ππQ. "Why do I get runtime error 4 while using the followingπ line: reset(InFile)?"ππA. The error message means that you have run out of fileπ handles. The FILES= statement in your CONFIG.SYS doesn'tπ change the fact that a process can, by default, open aπ maximum of 20 files (and DOS grabs 5 of those). Theπ SetHandleCount() API function can be used to increase theπ number of handles useable by your application.ππQ. "I am using overlays with BP7 with Objects. If Overlay Aπ calls a procedure or function in Overlay B, does Overlay Aπ stay in memory while Overlay B runs? Or does Overlay Bπ wipe out Overlay A, and when Overlay B finishes, it reloadsπ Overlay A?"ππA. It depends on the size of the overlays and the size of theπ overlay buffer you set up. In general you can think of theπ overlay buffer as a pool of memory where overlaid units canπ be stored. Every time you call a routine in an overlaidπ unit, that overlay is loaded into the buffer. If theπ buffer is already full, then the oldest unit in the bufferπ is discarded to make room for the new one. If you've got aπ small overlay buffer and large overlaid units, they mayπ well kick each other out as they load. If you've got aπ large overlay buffer the program may well keep everythingπ in memory the entire time.π πQ. "I am getting DosError = 8 when using EXEC() to execute a π program from within my program. How do I correct this?"ππA. DosError = 8 means that there is not enough memory π available to run the program being EXEC'ed. Normally yourπ program grabs all available memory and doesn't leave any π for the program being EXEC'ed. Be sure to use the $M π directive which minimizes the memory required by yourπ program. ππQ. "I am getting DosError = 2 when using EXEC() to copy a π file from one directory to another. The file does existπ and the command line is correct. What is the problem?"πA. You might have assumed that because COMMAND.COM is on yourπ path, EXEC will find it. Nope. EXEC needs the full pathπ name. You can use GetEnv('COMSPEC') to get the value ofπ the environment variable COMSPEC which should be the fullπ path. π πππ 5 05-26-9406:12ALL SWAG SUPPORT TEAM OWL/BWCC FAQ SWAG9405 36 ~O SECTION 8 - OWL/BWCCππThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.π πTI1203 Using Validators in OWL ApplicationsπTI1262 Installation notes regarding Turbo Debugger for WindowsπTI1171 Borland problem report formπTI607 Description and illustration of printing in WindowsπTI992 Demonstration of collections and listboxes in WindowsππQ. "Why do I get 'Application Error -1' when my dialog triesπ to execute?"ππA. This error is basically a "Failure to create dialog" error.π Most often it is caused by one of two things:ππ 1. Failure to include "BWCC" in your USES clause. If youπ designed a dialog in Resource Workshop using the π Borland "look and feel", you need to include "BWCC" inπ your USES clause.ππ 2. Incorrect dialog identifier passed to dialog's Initπ method. Make sure the identifier you are passing toπ the dialog's Init method is the same one you are usingπ in Resource Workshop.ππQ. "How can I obtain the latest copy of BWCC.DLL?"ππA. Download BWCC.ZIP from library 2.ππQ. "What causes the 'Data Segment too large' compiler error?π How do I get rid of it?"ππA. This error occurs when your application has more than 64Kπ of information that it is trying to put into yourπ application's data segment. Note that you only have one 64Kπ data segment to work with, so you should manage this memoryπ judiciously. The following data is kept in an Object Windowsπ application's data segment:ππ * All global variablesπ * All typed constantsπ * Stackπ * Local Heap (used internally by Windows)π * Virtual Method Tableππ To avoid this error, you should take the following steps:ππ * Avoid large global variables. Try instead declaringπ larger variables on the heap using New() orπ GetMem(), and keeping a pointer to that variableπ globally.ππ * Keep your stack down to a reasonable size. 16K isπ usually a good amount for most applications.ππ * Avoid making functions in your objects Virtualπ unless they have to be; this will reduce the size ofπ the Virtual Method Table.ππQ. "How can I enable or disable a particular control in aπ dialog box?ππA. Use the EnableWindow(Wnd: Hwnd, Enable: Bool) API function. π It takes two parameters, the handle to the window (rememberπ a control is a window) to be enabled/disabled and a booleanπ value - True for enable and False for disable.ππQ. "How do I obtain the handle or ID of a control?" ππA. If you have a pointer to a control object, OWL will giveπ you the window handle automatically through the HWindowπ field; PointerToMyControl^.HWindow is the window handle.ππ If you know the handle of a control, you can obtain the IDπ by calling the GetDlgCtrlID() API function:ππ ControlID := GetDlgCtrlID(ControlHandle);ππ If you don't have a pointer to your control, but know theπ ID of a control, you can obtain the handle by calling theπ GetDlgItem() API function:ππ ControlHandle := GetDlgItem(DialogHandle, ControlID);π πQ. "How can I put Object Windows objects in a DLL?"ππA. OWL was not designed to be used in a DLL. Some users haveπ managed to get this to work in some cases, but it is not aπ practice that Borland recommends. For info on launching π windows and dialogs from a DLL without OWL, downloadπ APIDLL.PAS from library 2.ππQ. "Can a TFileWindow object edit files larger than 64K?"ππA. No. A TFileWindow is really just a multi-line edit controlπ that takes up the whole client area. An edit control'sπ buffer is allocated from the local heap, and therefore is π usually much smaller than 32K. If you would like to have π more buffer space, download GLBEDT.ZIP from library 8 - thisπ file provides you with a greater buffer for the TEdit andπ TFileWindow objects.ππQ. "How do I apply to become a beta tester for a futureπ Borland Pascal product?"ππA. Download SURVEY.ZIP from library 2.π π 6 05-26-9406:12ALL SWAG SUPPORT TEAM Windows API FAQ SWAG9405 17 ~O SECTION 9 - Windows APIππThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.ππTI607 How to print in windows. ππQ. "How can I enable or disable a particular control in aπ dialog box?"ππA. Use the EnableWindow(Wnd: Hwnd, Enable: Bool) API function. π It takes two parameters, the handle to the window (rememberπ a control is a window) to be enabled/disabled and a booleanπ value - True for enable and False for disable.ππQ. "How do I obtain the handle or ID of a control?" ππA. If you have a pointer to a control object, OWL will give youπ the window handle automatically through the HWindow field; π PointerToMyControl^.HWindow is the window handle.ππ If you know the handle of a control, you can obtain the IDπ by calling the GetDlgCtrlID() API function:ππ ControlID := GetDlgCtrlID(ControlHandle);ππ If you don't have a pointer to your control, but know the IDπ of a control, you can obtain the handle by calling theπ GetDlgItem() API function:ππ ControlHandle := GetDlgItem(DialogHandle, ControlID);ππQ. "How do I unload an abnormally terminated program's dlls?"ππA. By using GetModuleHandle to return the dll's handle, andπ then call freelibrary until GetModuleHandle returns 0. If aπ dll has loaded another dll, unload the child dll first.ππQ. "How do I hide a minimized icon without taking the programπ off the task list?"ππA. Move the icon off the display using SetWindowPos orπ MoveWindow and give negative coordinate values beyond theπ screen.ππQ. "How do I change a dll's data segment from fixed toπ movable?"ππA. Call GlobalPageUnloch(DSEG) in the outer block of your dll. π This will work providing the dll does not contain code thatπ requires a page locked data segment.πππ 7 05-26-9406:12ALL SWAG SUPPORT TEAM Windows Tools FAQ SWAG9405 27 ~O SECTION 10 - Windows ToolsππThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.π πTI1037 Configuring/Using Turbo Debugger for WindowsπTI1262 Installation notes regarding Turbo Debugger for WindowsπTI1171 Borland problem report formππQ. "Should I save my Resource Workshop projects as a .RES fileπ or a .RC file?"ππA. Since .RC files are ASCII text, it is easier to debug themπ and share them with other programmers, so it is usually bestπ to save your project as a .RC file and have it automaticallyπ create a .RES file for you. To do this, first create a .RCπ project. Then go to File|Preferences, and select the checkπ box next to "Multi-Save .RES file." Now, every time you saveπ your project, a .RES file will be created for you.ππQ. "What are WinSpector and WinSight?"ππA. WinSpector is a utility that allows you to perform a post-π mortem inspection of your windows applications that haveπ crashed as a result of a General Protection Fault orπ Unrecoverable Application Error. WinSpector can show you:ππ * The call stack.π * function and procedures names in the call stack (withπ a little help from you).π * CPU registers.π * A disassembly of the instructions.π * Windows information.π π WinSight is a utility that gives you information aboutπ window classes, windows, and messages while an applicationπ is running. You can use it to study how any applicationπ creates classes and windows, and to see how windows send andπ receive messages.ππQ. "Why does my screen get scrambled when I run Turbo Debuggerπ for Windows?"ππA. The Turbo Debugger video DLL you are using is probablyπ incompatible with your Windows graphics driver. Downloadπ TDSVGA.ZIP from library 2, and try one of the differentπ video DLLs.ππQ. "I have a rather large application, and it does not seem toπ work correctly in Turbo Debugger for Windows or Turboπ Profiler for Windows. What's the problem?"ππA. Turbo Debugger for Windows and Turbo Profiler for Windows doπ have limitations in the size of the files and number ofπ symbols they can handle. If you find you are encounteringπ this problem, the best solution is to modularize your codeπ into several discreet objects that can be individuallyπ debugged.ππQ. "I just installed Borland C++ 4.0, and I have TPW 1.5 or BPπ 7.0. Why am I having problems getting the Pascal Turboπ Debugger for Windows to work correctly?"ππA. There are three main things to check on here:ππ 1. Make sure \BP\BIN (or \TPW\BIN) is in your PATHπ statement before \BC4\BIN.π 2. Make sure you are loading the version of TDDEBUG.386π in the [386Enh] section of SYSTEM.INI) that comes withπ Pascal.π 3. Rename the TDW.INI file that came with BC4, so thatπ Pascal will create its own new INI file.ππ Also, you may wish to download TI1037 from library 2. Thisπ has some good information on TDW.ππ 8 05-26-9406:12ALL SWAG SUPPORT TEAM Networks FAQ SWAG9405 20 ~O SECTION 16 - Networksπ πThis document contains information that is most often providedπto users of this section. There is a listing of commonπTechnical Information Documents that can be downloaded from theπlibraries, and a listing of the five most frequently askedπquestions and their answers.ππTI555 File and record locking in Turbo PascalπTI1201 Installing Turbo Pascal on a networkππQ. "How do I open a file in read only mode?"ππA. Turbo Pascal gives you the ability to open files in severalπ different modes. Typically, you will want to change theπ file mode after you call Assign but before you call Reset orπ ReWrite. You make the change by assigning numerical valuesπ to the built in FileMode variable.ππQ. "What is the default value for FileMode? What values areπ associated with a shared Read/Write mode and a shared Readπ only mode."ππA. By default, FileMode is set to 2. Set FileMode to 66 toπ acheive a shared Read/Write mode, and set it to 64 to get aπ shared Read only mode.ππQ. "How can I implement file and record locking in my ownπ code?"ππA. Turbo Pascal has no built in functions for file and recordπ locking, so you have to go to the assembler level (orπ call MsDos/Intr) to implement this feature. With DOSπ versions 3.0 and later, you can access file and recordπ locking via Interrupt $21, Service $5C, SubFunctions 0 andπ 1. (See TI555, and the next Q/A.).ππQ. "Beside the method described above, is there a second way toπ access file and record locking routines?"ππA. Real world implementations of record and file locking tendπ to be very complex to implement. As a result, it is standardπ practice for programmers to gain access to this kind ofπ functionality by purchasing a ready made database toolkitπ such as the Borland Database Engine (release date, summerπ 94), the B Tree Filer from Turbo Power software, or theπ Paradox Engine.ππQ. "How can I get access to Netware and other networkπ routines?"ππA. Turbo Pascal provides no built in access to Netware orπ other network functions other than the calls that are builtπ into Windows, such as WNetAddConnection,π WNetCancelConnection, and WNetGetConnection. In theπ Compuserve library for Section 16 there are (as of May 94)π various toolkits available, such as the MAPI.ZIP andπ TPAPI.ZIP files.π